package test.skymobi.http.file;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

public class HttpStaticFileServer {
	private static int port;

	public void run() throws Exception {
		ServerBootstrap b = new ServerBootstrap();

		b.group(new NioEventLoopGroup(), new NioEventLoopGroup())
				.channel(NioServerSocketChannel.class).localAddress(port)
				.childHandler(new HttpStaticFileServerInitializer());

		b.bind().sync().channel().closeFuture().sync();

	}

	public static void main(String[] args) throws Exception {
		if (args.length > 0) {
			port = Integer.parseInt(args[0]);
		} else {
			port = 8080;
		}
		new HttpStaticFileServer().run();
	}
}
